package com.moli.iov.open.config;

import com.moli.iov.open.web.interceptor.AuthInterceptor;
import com.moli.iov.open.web.interceptor.TokenInterceptor;
import javax.annotation.Resource;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * <p>
 *
 * </p>
 *
 * @author zql
 * @since 2019/8/30 11:48
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {

  @Resource
  private TokenInterceptor tokenInterceptor;

  @Resource
  private AuthInterceptor authInterceptor;

  /**
   * 注册拦截器
   * @param registry
   */
  @Override
  public void addInterceptors(InterceptorRegistry registry) {
    registry.addInterceptor(tokenInterceptor)
        .addPathPatterns("/**")
        .excludePathPatterns("/token");

    registry.addInterceptor(authInterceptor)
        .addPathPatterns("/**")
        .excludePathPatterns("/token");

  }
}
